# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: team/kde <bribbers@disroot.org>

# The group tag is just to easily find this APKBUILD by some scripts for automation
# group=kde-other
pkgname=calligra
pkgver=4.0.1
pkgrel=11
pkgdesc="Office and graphic art suite by KDE"
# armhf blocked by extra-cmake-modules
# armv7 and x86 are broken
# s390x, ppc64le, riscv64 and loongarch64 blocked by qt6-qtwebengine -> okular
arch="all !armhf !armv7 !x86 !s390x !ppc64le !riscv64 !loongarch64"
url="https://calligra.org/"
license="GPL-2.0-or-later AND LGPL-2.0-only"
makedepends="
	attica-dev
	boost-dev
	eigen-dev
	extra-cmake-modules
	karchive-dev
	kcmutils-dev
	kcodecs-dev
	kcompletion-dev
	kconfig-dev
	kconfigwidgets-dev
	kcoreaddons-dev
	kdbusaddons-dev
	kdiagram-dev
	kdoctools-dev
	kguiaddons-dev
	ki18n-dev
	kiconthemes-dev
	kio-dev
	kitemviews-dev
	kjobwidgets-dev
	knewstuff-dev
	knotifications-dev
	knotifyconfig-dev
	kparts-dev
	ktextwidgets-dev
	kwallet-dev
	kwidgetsaddons-dev
	kwindowsystem-dev
	kxmlgui-dev
	poppler-qt5-dev
	qt6-qtbase-dev
	qt6-qtdeclarative-dev
	qt6-qtsvg-dev
	qtkeychain-dev
	samurai
	sonnet-dev
	threadweaver-dev
	"
# Dependencies for extra features
makedepends="$makedepends
	libgit2-dev
	libodfgen-dev
	libvisio-dev
	libwpg-dev
	okular-dev
	"
checkdepends="xvfb-run"
source="https://download.kde.org/stable/calligra/calligra-$pkgver.tar.xz"
subpackages="$pkgname-doc $pkgname-lang"
options="!check" # Broken tests https://bugs.kde.org/show_bug.cgi?id=423989

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DGHNS=ON \
		-DBUILD_TESTING="$(want_check && echo ON || echo OFF)"
	cmake --build build
}

check() {
	xvfb-run ctest --test-dir build --output-on-failure
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
79569a1e75d5c70c8b2c3e5c7cf88d26d9b7a81be52c131c932521c65d1712a531829bcd29f7233f1ee7601fa363ca9ce2c4783a76dfdc5abe3c8b04b5741b78  calligra-4.0.1.tar.xz
"
